import Layout from '@/layout/index.vue'
const modules = import.meta.glob('./modules/*.js', { eager: true })

const routeModuleList = []
// 加入到路由集合中
Object.keys(modules).forEach((key) => {
  const mod = modules[key].default || {}
  const modList = Array.isArray(mod) ? [...mod] : [mod]
  routeModuleList.push(...modList)
})

const routes = [
  {
    path: '/main',
    name: 'main',
    redirect: '/home',
    component: Layout,
    children: routeModuleList,
    meta: {}
  }
]

export default routes
